"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    loader.define(['pages/config/config'], function (config, require, exports, module, global) {
      var pageview = {};

      pageview.init = function () {
        var data_ = {
          groupid: '36'
        };
        data_ = JSON.stringify(data_);
        bui.ajax({
          // url: 相对路径
          url: config.apiurl + "api/v1.0/getMemberInfo",
          data: data_,
          method: "post",
          headers: {
            'Content-Type': 'application/json'
          }
        }).then(function (res) {
          console.log(res);
          var gname, gintro, gimg;
          gname = res.groupname;
          gintro = res.groupintroduction == null ? '群主很懒~什么也没有写' : res.groupintroduction; // gimg = 'images/other/35.jpg';

          gimg = res.groupavatar;
          $("#msg-name").text(gname);
          $("#msg-intro").text(gintro);
          $(".detail-image img").attr("src", gimg);
          var member = res.data;
          $("#nummem span").text('共' + member.length + '人');
          $(".member-list").html("");

          for (var i = 0; i < 6; i++) {
            var item = $('<div class="span2 bui-box-center bui-box-vertical member-item"></div>');

            if (i < member.length) {
              // console.log(member[i]);
              var item_img = $('<div class="item-img"></div>');
              var tempimg = $('<img>');
              tempimg.attr('src', member[i].avatar_url);
              item_img.append(tempimg);
              var item_name = $('<div class="item-name"></div>');
              item_name.text(member[i].name);
              item.append(item_img);
              item.append(item_name);
            }

            $(".member-list").append(item);
          }

          $(".detail-msg").on("click", function (e) {
            bui.load({
              url: 'pages/groupdetail/groupdetail',
              param: {
                gname: gname,
                gintro: gintro,
                gimg: gimg
              }
            });
          });
          $(".detail-more").on("click", function (e) {
            bui.load({
              url: 'pages/groupdetail/groupdetail',
              param: {
                gname: gname,
                gintro: gintro,
                gimg: gimg
              }
            });
          });
          $("#group-member").on("click", function () {
            bui.load({
              url: 'pages/groupmember/groupmember',
              param: {
                msg: member
              }
            });
          });
          $("#btn-gname").on("click", function () {
            bui.load({
              url: 'pages/groupname/groupname',
              param: {
                gname: gname
              }
            });
          });
          $("#btn-mute").on("click", function () {
            bui.load({
              url: 'pages/groupmute/groupmute',
              param: {
                msg: member
              }
            });
          });
        }, function (res, status) {
          console.log(status);
        }); // var temp = [
        //     {
        //         head: 'images/other/35.jpg',
        //         name: 'Jackson',
        //         phone: '13570512160',
        //         ismute: false
        //     }
        // ]
        // $("#detail-image").on("click", function(){
        //     console.log('hhh');
        // });

        function Photo(url) {
          return "<img src=\"".concat(url, "\" style=\"width:auto;height:auto;max-width:100%;max-height:100%;margin: auto;position: absolute;top: 0;left: 0;right: 0;bottom: 0;\"/>");
        }

        function checkphoto1(src) {
          var $checkarea = $("#checkphoto21"); // 查看照片弹出框

          var uiDialog11 = bui.dialog({
            id: "#dialogCheck1",
            fullscreen: true,
            appendTo: "body",
            onBeforeOpen: function onBeforeOpen() {
              $checkarea.html(Photo(src));
            }
          });
          uiDialog11.open();
        }

        var uiUpload = bui.upload({
          showProgress: true // needNative: false

        });
        var uiActionsheet = bui.actionsheet({
          trigger: "#detail-image",
          appendTo: ".chatgroup-page",
          buttons: [{
            name: "查看头像",
            value: "check"
          }, {
            name: "更改头像",
            value: "photo"
          }],
          callback: function callback(e) {
            var ui = this;
            var val = $(e.target).attr("value");

            switch (val) {
              case "photo":
                ui.hide();
                uiUpload.add({
                  "from": "",
                  "needCompress": true,
                  // 1.5.3新增压缩
                  "onSuccess": function onSuccess(val, data) {
                    // 展示base64本地图片 建议直接调用start方法上传以后再展示远程地址,避免应用崩溃
                    this.toBase64({
                      onSuccess: function onSuccess(url) {
                        bui.load({
                          url: "pages/groupclip/groupclip",
                          param: {
                            url: url
                          }
                        });
                      }
                    });
                  }
                });
                break;

              case "check":
                ui.hide();
                var data_ = {
                  groupid: 36
                };
                data_ = JSON.stringify(data_);
                bui.ajax({
                  url: config.apiurl + "api/v1.0/getGroupAvatar",
                  data: data_,
                  method: "post",
                  headers: {
                    'Content-Type': 'application/json'
                  }
                }).done(function (res) {
                  console.log(res);
                  var personimage = res['avatar_url'];
                  personimage = personimage + "?temp=" + Date.now(); //在src后面增加一个随机数避免图片无法更新

                  checkphoto1(personimage);
                }).fail(function (res, status) {
                  console.log(status);
                }); // checkphoto1(gimg);

                break;

              case "cancel":
                ui.hide();
                break;
            }
          }
        });
      };

      pageview.init();
      return pageview;
    });
  }, {}]
}, {}, [1]);